<html>
<head>
<title>Regular Expressions Quick Reference</title>
<meta name="keywords" content="regular expressions cheat sheet">
<STYLE type="text/css">
H3 {text-align: center; font-variant: small-caps; font-size: 10pt;}
CODE {color: green; font-size: 8pt;}
P {font-size: 8pt;}
</STYLE>
</head>
<body>


<h3>Regular Expressions Quick Reference</h3>
<p>
<br/><br/><b>Captured text</b>
<br/>Text is captured using brackets.<code>(a)</code> will capture letter a, if found.
<code>(.*)</code> captures all letters.<!--  -->
<br/><br/><b>Regular letters</b>
<br/>In Regular Expressions, most of the symbols have their usual meaning.
Letter <code>a</code> will find a hit in <code>xay</code> at offset 1.<!--  -->
<br/><br/><b>Logical or</b>
<br/>Words may be used together using constructs like <code>word1|word2|word3</code><!--  -->
<br/>To match one letter in a group, square brackets are used to show allowed range. 
For example, <code>[ab]</code> will find a hit in <code>xay</code> at offset 1 and
in <code>xyb</code> at offset 2. It translates to a or b.<!--  -->
<br/>Angle brackets may contain ranges in the form <code>[a-z]</code> 
for example, that will match any english letter. <code>[a-d]</code> is identical
to <code>[abcd]</code><!--  -->
<br/><br/><b>Counted occurences</b>
<br/>Each item that is searched may have a quantifier in the form <code>x{1,5}</code>, where 1 means that
at least one x must be found and 5 tells that no more than five characters will be matched.
As such, <code>[0-9]{1,2}</code> will match strings having one or two characters that consist of digits.<!--  -->
<br/><code>*</code> applied after an item matches zero or more occurrences of that item<!--  -->
<br/><code>?</code> applied after an item matches zero or one occurrences of that item<!--  -->
<br/><code>+</code> applied after an item matches one or more occurrences of that item<!--  -->
<br/><br/><b>Special markers</b>
<br/><code>\s</code> is used to match exactly one white space and <code>\S</code> negates this.<!--  -->
<br/><code>\b</code> indicates a word boundary.<!--  -->
<br/><code>\w</code> indicates a word character (including underscore) and <code>\W</code> a non-word character.<!--  -->
<br/><code>\d</code> is same as writing <code>[0-9]</code>, while <code>\D</code> matches a non-digit.<!--  -->
<br/><code>\\</code> construct is used to enter an actual "back-slash".<!--  -->
<br/><code>^</code> is string start and <code>$</code> is string end.<!--  -->
<br/><code>^</code> negates the expresion following it.<!--  -->
<br/><code>(?__)</code> is positive look-ahead and <code>(?!__)</code> is negative counterpart.<!--  -->
<br/><br/><b>Examples</b>
<br/><code>&lt;title>(.*)&lt;/title></code> gets the title of a html document<!--  -->
<br/><code>&lt;a[^>]*>(.*)&lt;/a></code> gets the text portion of an anchor<!--  -->
<br/><code>&lt;a.*href\s*=\s*[\"|'](.*)[\"|']</code> gets the link portion of an anchor<!--  -->

</p>


</body>
</html>
